/**
 * 
 */
package fr.lelouet.ga.examples.multOf11;

import fr.lelouet.ga.reducers.Evaluator;

/**
 * @author guigolum
 */
public class ElevenMultiplicatorEvaluator implements Evaluator<Integer> {

  @Override
  public double eval(Integer target) {

    int ode = 0;
    int even = 0;
    boolean nextOde = true;
    while (target > 0) {
      if (nextOde) {
        ode += target % 10;
      } else {
        even += target % 10;
      }
      nextOde = !nextOde;
      target = target / 10;
    }
    return (200 / (Math.abs(ode - even) + 2));
  }

}
